<template>
    <div class="temai">
        <van-nav-bar title="优选卖场" left-text="返回" left-arrow @click-left="onClickLeft" />
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
            <van-cell v-for="item in list" :key="item.id" @click="toDetail(item.id)">
                <div>
                    <img :src="item.picture" alt="">
                    <span>{{ item.shop }}</span><br>
                    <span class="zk">2.5折</span>
                    <span>{{ item.product }}</span>
                </div>
            </van-cell>
        </van-list>
    </div>
</template>
<script>
import axios from 'axios'
export default {
    data() {
        return {
            list: [],
            finished: false,
            loading: false,
            pageNo:1
        }
    },
    created() {
        // axios({
        //     url: 'http://api.yuguoxy.com/api/shop/list',
        //     method: 'get',
        //     params: {
        //         pageSize: 10,
        //         pageNo: this.pageNo
        //     }
        // }).then(res => {
        //     console.log(res);
        //     this.list = res.data.resultInfo.list
        // })
    },
    methods: {
        onClickLeft() {
            this.$router.go(-1)
        },
        onLoad() {
            this.loading = true
            console.log(this.pageNo);
            axios({
                url: 'http://api.yuguoxy.com/api/shop/list',
                method: 'get',
                params: {
                    pageSize: 10,
                    pageNo: this.pageNo
                }
            }).then(res => {
                if(res.resultCode = 1){
                    console.log(res);
                    this.list = [...this.list,...res.data.resultInfo.list]
                    this.loading = false
                    this.pageNo++
                }else{
                    this.finished = true
                }
            })
        },
         toDetail(id) {
            console.log('今日秒杀', id);
            this.$router.push('/detail' + '?id=' + id)
        }
    }
}
</script>

<style lang="scss" scoped>
.temai .zk {
    padding-right: 20px;
    color: #E47B96;
}

.temai div img {
    width: 100%;
}

.fh {
    padding-right: 20px;
    float: left;
}

.tm {
    margin-left: 70px;
    float: left;
}
</style>
